package com.boomsecret.juc.atomic;

import java.util.concurrent.atomic.LongAccumulator;

/**
 * @author wangjinliang on 2019/1/17.
 */
public class LongAccumulatorDemo {

    public static void main(String[] args) {
        LongAccumulator longAccumulator = new LongAccumulator((left, right) -> {
            System.out.println("left:" + left);
            System.out.println("right:" + right);
            return left * right;
        }, 3);
        System.out.println(longAccumulator.get());

        System.out.println("-------------");
        longAccumulator.accumulate(4);
        System.out.println(longAccumulator.get());
    }
}
